package com.example.understandvideo.controller;

import com.example.understandvideo.pojo.MarathonGroup;
import com.example.understandvideo.pojo.MarathonPlayer;
import com.example.understandvideo.pojo.ResultFul;
import com.example.understandvideo.pojo.request.ClipTaskRequest;
import com.example.understandvideo.pojo.request.CommonSearchRequest;
import com.example.understandvideo.pojo.request.MarathonTaskSaveRequest;
import com.example.understandvideo.pojo.request.MarathonTaskSearchRequest;
import com.example.understandvideo.service.transcode.SportProcessor;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 马拉松的任务
 */
@RestController
@RequestMapping("/api/gateway/task/marathon")
public class MarathonTaskController {
    @Resource
    SportProcessor sportProcessor;
    @RequestMapping(value = "/task/add", method = RequestMethod.POST)
    public ResultFul addTask(@RequestBody MarathonTaskSaveRequest request) {
        sportProcessor.put(request);
        return ResultFul.OK();
    }
    @RequestMapping(value = "/task/search", method = RequestMethod.POST)
    public ResultFul searchTask(@RequestBody MarathonTaskSearchRequest request) {
        return ResultFul.OK(sportProcessor.list(request));
    }

    //todo 处理结果
    @RequestMapping(value = "/task/detail", method = RequestMethod.POST)
    public ResultFul detail(@RequestParam (value = "id", required = false) Long id) {

        return ResultFul.OK(sportProcessor.detail(id));
    }


    @RequestMapping(value = "/task/clips", method = RequestMethod.POST)
    public ResultFul clipTask(@RequestBody ClipTaskRequest request) {
        return sportProcessor.clipTask(request);
    }

    @RequestMapping(value = "/player/add", method = RequestMethod.POST)
    public ResultFul addPlayer(@RequestBody MarathonPlayer model) {
        sportProcessor.addPlayer(model);
        return ResultFul.OK();
    }

    @RequestMapping(value = "/player/search", method = RequestMethod.POST)
    public ResultFul searchPlayer(@RequestBody MarathonTaskSearchRequest request) {
        return ResultFul.OK(sportProcessor.searchPlayer(request));
    }

    @RequestMapping(value = "/group/add", method = RequestMethod.POST)
    public ResultFul addGroup(@RequestBody MarathonGroup model) {
        sportProcessor.addGroup(model);
        return ResultFul.OK();
    }

    @RequestMapping(value = "/group/search", method = RequestMethod.POST)
    public ResultFul searchGroup(@RequestBody CommonSearchRequest request) {
        return ResultFul.OK(sportProcessor.searchGroup(request));
    }
}
